package com.army.modules.batch.job;

import com.army.common.utils.BusinessException;
import com.army.modules.batch.entity.ABusiness;
import com.army.modules.batch.mapper.ABusinessMapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.batch.core.JobExecution;
import org.springframework.batch.core.listener.JobExecutionListenerSupport;
import org.springframework.stereotype.Component;

@Slf4j
@Component
@AllArgsConstructor
public class DataToFileJobListener extends JobExecutionListenerSupport {
    private final ABusinessMapper aBusinessMapper;
    @Override
    public void afterJob(JobExecution jobExecution) {
        log.info("发送给房管局的文件写入完成");
        UpdateWrapper<ABusiness> wrapper = new UpdateWrapper<>();
        wrapper.eq("status",01);
        wrapper.eq("send_status","00");
        wrapper.set("send_status","01");
        int update = aBusinessMapper.update(new ABusiness(), wrapper);
        if (update==0){
            throw new BusinessException("更新发送状态失败");
        }
    }
}
